<?php
if($_POST['tab'] && $_POST['tab']!=""){
	$tab = $_POST['tab'];
}else{
	$tab = 'prayer';
	
}
//echo '<br />'.$_POST['savecontent'];
//echo '<br />'.$_POST['tab'];
//echo '<br />'.$_POST['mce'];
//echo '<br />'.$site['id'];
if($_POST['savecontent']=="Save"){
	if($_POST['tab'] && $_POST['tab']!=""){
		$tab = $_POST['tab'];
		$mce = urlencode(trim($_POST['mce']));
		$siteid = $site['id'];
		dbUpdate('sites',array("$tab='$mce'"),array("id=$siteid"));
	}
}
?>
<h2>Needs</h2>
<form name="contentform" action="<?php echo $thisroot ?>/needs.php" method="post">
<table>
	<tr>
		<td>
			<span class="fakelink" id="prayer" onclick="linkContent('prayer');">Prayer</span>&nbsp;&nbsp;|&nbsp;
			<span class="fakelink" id="people" onclick="linkContent('people');">People</span>&nbsp;&nbsp;|&nbsp;
			<span class="fakelink" id="stuff" onclick="linkContent('stuff');">Stuff</span>&nbsp;&nbsp;|&nbsp;
			<span class="fakelink" id="money" onclick="linkContent('money');">Money</span><br /><br />
		<?php
			echo "<script type=\"text/javascript\">document.getElementById('".$tab."').style.color='#0094FF';</script>";
			echo 	'<div align="left" width="650">';
			
		if($isadmin){
			echo '<!---<span class="fakelink" onclick="toggleEditor(\'mce\');">Preview</span><br />--->
				<textarea class="mceEditor" name="mce" id="mce">';
		}
		if($_POST['savecontent'] && $_POST['savecontent']=="Save"){
			echo urldecode($mce);
		}else{
			if($tab=='people'){echo urldecode($site['people']);}elseif($tab=='stuff'){echo urldecode($site['stuff']);}elseif($tab=='money'){echo urldecode($site['money']);}else{echo urldecode($site['prayer']);}
		}
		if($isadmin){
			echo '</textarea>';
			$formmode = 'edit';
		}else{
			$formmode = 'link';
		}
		echo '</div>';

		?>
		</td>
	</tr>
	<?php if($isadmin){
	echo '<tr>
		<td align="right">
			<input type="submit" name="savecontent" value="Save" />
		</td>
	</tr>';
	} ?>
</table>
			<input type="hidden" name="mode" value="<?php echo $formmode; ?>" />
			<input type="hidden" name="tab" value="<?php echo $tab; ?>" />
</form>
